import { defHttp } from '/@/utils/http/axios';

enum Api {
  listNoCareTenant = '/book/listAll',
  deleteUser = '/book/delBook',
  save = '/book/add',
  edit = '/book/edit',
}

/**
 * 列表接口
 * @param params
 */
export const listNoCareTenant = (params) => defHttp.get({ url: Api.listNoCareTenant, params });

/**
 * 删除书籍
 */
export const deleteBook = (params, handleSuccess) => {
  return defHttp.delete({ url: Api.deleteUser, params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess();
  });
};

/**
 * 保存或者更新书籍
 * @param params
 */
export const saveOrUpdateBook = (params, isUpdate) => {
  const url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({ url, params });
};
